package my.rest.resources;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import my.rest.resources.dm.VehicleModelInfoDataManager;
import my.rest.resources.model.VehicleModelInfo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Path("/info")
public class VehicleModelInfoProvider {

	@Context
	UriInfo uriInfo;

	@Context
	Request request;

	Logger logger = LoggerFactory.getLogger(getClass());

	private VehicleModelInfoDataManager vehModelDm;

	@GET
	@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
	public VehicleModelInfo provideInfo(@Context HttpServletRequest request){
		String model = request.getParameter("model");
		logger.debug("model from request {}",model);
		logger.debug("DataManager {}",vehModelDm);
		return vehModelDm.retrieveInfo(model);
	}

	/**
	 * @param vehModelDm the vehModelDm to set
	 */
	public void setVehModelDm(VehicleModelInfoDataManager vehModelDm) {
		this.vehModelDm = vehModelDm;
	}

}
